package week;

import org.apache.spark.SparkConf;
import org.apache.spark.api.java.JavaPairRDD;
import org.apache.spark.api.java.JavaRDD;
import org.apache.spark.api.java.JavaSparkContext;
import org.apache.spark.input.PortableDataStream;

public class Work2 {

    int checkDirectory() {



        return 0;
    }

    public int copyDirectory(String source, String target) {
        SparkConf sparkConf = new SparkConf();
        sparkConf.setAppName("geektimeBigDataWeek6Work2");
        sparkConf.setMaster("local[*]");

        JavaSparkContext sparkContext = new JavaSparkContext(sparkConf);

        JavaPairRDD<String,PortableDataStream> rddFile = sparkContext.binaryFiles(source);
        rddFile.saveAsTextFile(target);

        return 0;
    }

    public static void main(String[] args) {
        String source = "hdfs://127.0.0.1/work2/source";
        String target = "hdfs://127.0.0.1/work2/target";

        Work2 work = new Work2();
        work.copyDirectory(source, target);
    }
}
